<?php

/**
 * Roles list view.
 *
 * @var \yii\web\View $this View
 * @var \yii\data\ArrayDataProvider $provider Data provider
 * @var array $generatePermissions
 */

use common\widgets\Box;
use common\widgets\GridView;
use common\modules\user\Module;
use yii\grid\CheckboxColumn;

$this->title = Module::t('user', 'BACKEND_ROLES_INDEX_TITLE');
$this->params['subtitle'] = Module::t('user', 'BACKEND_ROLES_INDEX_SUBTITLE');
$this->params['breadcrumbs'] = [
    $this->title
];

$gridId = 'roles-grid';
$gridConfig = [
    'id' => $gridId,
    'dataProvider' => $provider,
    'columns' => [
        [
            'class' => CheckboxColumn::classname()
        ],
        'name',
        'description',
        'ruleName',
        'data',
        'createdAt:date',
        'updatedAt:date',
        [
            'class' => 'yii\grid\ActionColumn',
            'template' => '{update} {delete}',
        ]
    ]
];

$boxButtons = $actions = [];
$boxButtons[] = '{create}';
$actions[] = '{update}';
//$boxButtons[] = '{batch-delete}';
$actions[] = '{delete}';

$boxButtons = !empty($boxButtons) ? implode(' ', $boxButtons) : null; ?>

<div class="row">
    <div class="col-xs-12">
        <?php Box::begin([
            'title' => $this->params['subtitle'],
            'bodyOptions' => [
                'class' => 'table-responsive'
            ],
            'buttonsTemplate' => $boxButtons,
            'grid' => $gridId,
        ]); ?>
        <?php echo GridView::widget($gridConfig); ?>
        <?php Box::end(); ?>
    </div>
</div>